<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta name="format-detection" content="telephone=no">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0,user-scalable=no">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
<title>Insert title here</title>
<style type="text/css">
		html{height:100%;}
		body{
			background:url(${ROOT_PATH }content/images/front/amani1_02.png) no-repeat;background-size: 100% 100%;height:100%;
		}
		#addCard{width:90%;heigth:20%;marign-top:20%;margin-left:4%;background: none;border:}
		.font-y{-webkit-text-fill-color: transparent; -webkit-background-clip: text; background-image: -webkit-gradient(linear, 0% 0%, 100% 0%, from(#D8C076), to(#A27E47));}
	</style>
</head>
<body> 
	<div id='addCard' class="font-y">获取卡券到卡包</div> 
	<script type="text/javascript" src='http://libs.baidu.com/jquery/1.11.1/jquery.min.js'></script>
	<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
	<script type="text/javascript">
		$(function() {
			 wx.config({
			        debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
			        appId: '${appId}', // 必填，公众号的唯一标识
			        timestamp:"${jsapi_timestamp}", // 必填，生成签名的时间戳
			        nonceStr: '${jsapi_nonceStr}', // 必填，生成签名的随机串
			        signature: '${jsapi_signature}', // 必填，签名，见附录1
			        jsApiList: ['addCard', 'hideOptionMenu'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
			    });

			 wx.ready(function () {
				 wx.hideOptionMenu();
				$("#addCard").bind("click", function(e) { 
					$.ajax({
						 type: "post",
				         url: "${ROOT_PATH}UCenter/sendCard/send",
				         data: {},
				         dataType: "json",
				         success: function (o) { 
				        	var cardInfo={cardId: o.cardId, cardExt: JSON.stringify(o.cardExt)};
				        	var addCardInfo={cardList:[],success: function (res) {
	                            if (res.cardList) {
	                                alert('添加卡包成功');
	                            } else{
	                                altTip('添加卡包失败');
	                            }
	                        }};
				        	addCardInfo.cardList.push(o);
			                wx.addCard(addCardInfo); 
				         },
				         error: function(XMLHttpRequest, textStatus, errorThrown) {
				        	 alert(XMLHttpRequest.status);
				        	 alert(XMLHttpRequest.readyState);
				        	 alert(textStatus);
				        	   }
					});
				});
						 
			 });
		});
	</script>
</body>
</html>